﻿<div class="input-group">
    <label class="input-group-addon column-prompt" for="Enterprise">所属企业</label>
    <select class="form-control" id="Enterprise" value="" style="100%" onchange="EnterpriseChanged(this)"></select>
</div>
<div class="input-group">
    <label class="input-group-addon column-prompt" for="Department">所属部门</label>
    <input class="form-control" id="Department" value="" style="width:100%" />
</div>
<script>
    function InitExtendData() {
        AjaxPostData('/Admin/ListEnterprise', { },
            function (result) {
                $('#Enterprise option').remove();
                for(r in result)
                $('#Enterprise').append("<option value='" + result[r].ID + "'>" + result[r].FullName + "</option>");
            });
    	}
    function EnterpriseChanged(btn, d) {
        AjaxPostData('/Admin/ListDepartment', {ID: $('#Enterprise').val()},
            function (result) {
                $('#Department').combotree({
								    data: result,
								    width:"300px"
								});
								if(d != undefined)$("#Department").combotree('setValue', d);
            });
    	}
    function CheckExtendData() { return ""; }
    function GetExtendData(data){ data["所属企业"] = $("#Enterprise").val();data["所属部门"] = $("#Department").val(); }
    function SetExtendData(data){ 
    	if(data == null) {
    		$("#Enterprise").val("");
    		$("#Department").val("");
    	}else{
    		if(data["所属企业"] != undefined){
    			$("#Enterprise").val(data["所属企业"]);
	    		EnterpriseChanged(null, data["所属部门"]);
	    	}
    	}
    }
</script>